package com.kurumi.autoprint.schedule;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.kurumi.autoprint.util.ExceptionUtil;
import com.kurumi.autoprint.util.FileUtil;


@Configuration     
@EnableScheduling 
public class SaticScheduleTask {
	private static final Logger log = LoggerFactory.getLogger(SaticScheduleTask.class);
	
	@Value("${PRINT_FILR_DIR}")
	private String printFileDir;
	
	//每天凌晨一点执行
    @Scheduled(cron = "0 10 1 ? * *")
    private void configureTasks() {
    	log.info("---开始执行定时任务, 删除printFileDir={}文件--", printFileDir);
    	
    	try {
			FileUtil.deleteNotTodayCreateFile(printFileDir);
		} catch (Exception e) {
			log.error("定时任务删除打印文件异常,printFileDir={}, exceptionMsg={}", printFileDir, ExceptionUtil.getStackTrace(e));
		}
    	
    	
    }
	
    
    
	

}
